import Vue from 'vue'
import axios from 'axios'
// axios.defaults.baseURL = 'http://192.168.2.55:8080/tc'; //本地接口

axios.defaults.baseURL = 'http://27.148.158.244:10101/ada'; //测试接口
import qs from 'qs'
axios.interceptors.request.use(function(config) {
    // 统一处理post请求的参数 为application/x-www-form-urlencode
    if (config.method == 'post') {
        config.data = qs.stringify(config.data)
    }
    return config;
});

// axios.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8';
// 登录验证模块
export const login = (agentId, kpassword) => {
    return axios.post(`/admin/admin.do?agentId=${agentId}&kpassword=${kpassword}`)
}

//代理查询模块
export const searh = (agentId) => {
    return axios.post(`/admin/agent.do?agentId=${agentId}&sessionId=${sessionStorage.getItem('token')}`)
}

// 获取所有代理
export const agents = (pageNo = 1) => {
    return axios.post(`/admin/agents.do?pageNo=${pageNo}&pageSize=5&sessionId=${sessionStorage.getItem('token')}`)
}

//查询代理的详情信息
export const selectagent = (agentId) => {
    return axios.post(`/admin/selectagentID.do?agentId=${agentId}&sessionId=${sessionStorage.getItem('token')}`)
}

//查询所有房间
export const userRooms = (pageNo = 1) => {
    return axios.post(`/user/userRooms.do?pageNo=${pageNo}&pageSize=5&sessionId=${sessionStorage.getItem('token')}`)
}

//根据房间ID查询房间
export const roomId = (roomId) => {
    return axios.post(`/user/userRoom.do?roomId=${roomId}&sessionId=${sessionStorage.getItem('token')}`)
}

//查询所有玩家
export const selectUsers = (pageNo = 1) => {
    return axios.post(`/user/selectUsers.do?pageNo=${pageNo}&pageSize=5&sessionId=${sessionStorage.getItem('token')}`)
}

//查询玩家
export const userId = (userId) => {
    return axios.post(`/user/selectUserId.do?userId=${userId}&sessionId=${sessionStorage.getItem('token')}`)
}

//根据ID代理充卡
export const addAgentGems = (agentId, gems) => {
    return axios.post(`/admin/addAgentGems.do?agentId=${agentId}&gems=${gems}&sessionId=${sessionStorage.getItem('token')}`)
}

//添加代理
export const addagent = (userId) => {
    return axios.post(`/admin/addagent.do?userId=${userId}&sessionId=${sessionStorage.getItem('token')}`)
}

//根据玩家id充值
export const addUserIditem = (gems) => {
    return axios.post(`/user/addUserIditem.do`,gems )
}

//点击搜索代理的充值记录
export const selectuserItem = (gems) => {
    return axios.post(`/admin/selectDateItmeAgent.do?gems=${gems}&sessionId=${sessionStorage.getItem('token')}`)
}


//点击一行搜索该代理的充值记录 详情页
export const down = (AgentId) => {
    return axios.post(`/admin/selectagentItem.do?AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}`)
}

//点击搜索玩家的充值记录
export const userselectuserItem = (gems) => {
    return axios.post(`/user/selectDateItmeAgent.do?gems=${gems}&sessionId=${sessionStorage.getItem('token')}`)
}

//点击一行搜索该代理的充值记录 详情页
export const downRe = (AgentId) => {
    return axios.post(`/user/selectuserItem.do?AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}`)
}


// .查询密码
export const agentselectpassword = (AgentId) => {
    return axios.post(`/admin/agentselectpassword.do?AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}` )
}

// 修改密码
export const updatepassword = (AgentId) => {
    return axios.post(`/admin/updatepassword.do?AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}`)
}





/******************************************************* */

//admin的个人信息 和 代理商个人信息 
export const person = (AgentId) => {
    return axios.post(`/admin/selectagentID.do?AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}`)
}


//这个是根据时间和代理id和和玩家id一起搜索
export const gameback = (AgentId) => {
    return axios.post(`/user/rollbackuser.do`,AgentId)
}


//代理和玩家充值回退  
export const gsendback = (AgentId) => {
    return axios.post(`/user/userrollback.do?AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}`)
}

//代理商根据代理id查询
export const gsendData = (AgentId) => {
    return axios.post(`/admin/rollbackagent.do??AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}`)
}


//经销商跟代理充值回退 agentId是经销商, imporiId是输入框的代理id
export const agentrollback = (AgentId) => {
    return axios.post(`/admin/agentrollback.do?AgentId=${AgentId}&sessionId=${sessionStorage.getItem('token')}`)
}